package lgs.hm.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.View;

import lgs.hm.model.User;

@Controller
@RequestMapping("user")
public class GetUserController {
	
	@RequestMapping("guser")
	@ResponseBody
	public Object getUser(@RequestParam("aaa") User user) {
		if(1==1) {
			throw new NullPointerException("数据库不见了");
		}
		return user;
	}
	
	@RequestMapping("mv")
	public ModelAndView hellmv() {
		Map<String, Object> map = new HashMap<>();
		map.put("banner", "天生我材必有用");
		ModelAndView modelAndView = new ModelAndView("h",map);
		return modelAndView;
	}
	
	@RequestMapping("print")
	public void aaa(HttpServletResponse hsr) {
		hsr.setContentType("text/HTML;charset=utf-8");
		try {
			hsr.getWriter().println("<h1>这里是打印输出流</h1>");
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		
	}

}
